﻿using Microsoft.CodeAnalysis.Diagnostics;
using RoslynPad.Roslyn;
using System.Collections.Immutable;
using System.Reflection;

namespace AiMoWindows.MainActions.ScriptActions
{
    class CustomRoslynHost(RoslynHostReferences? references = null, ImmutableHashSet<string>? disabledDiagnostics = null) : RoslynHost(AdditionalAssemblies, references, disabledDiagnostics)
    {

        static HashSet<Assembly> AdditionalAssemblies => new HashSet<Assembly>
            {
                Assembly.Load("RoslynPad.Roslyn.Windows"),
                Assembly.Load("RoslynPad.Editor.Windows")
            };

        private bool _addedAnalyzers = false;

        //public CustomRoslynHost(IEnumerable<Assembly>? additionalAssemblies = null, RoslynHostReferences? references = null, ImmutableHashSet<string>? disabledDiagnostics = null, ImmutableArray<string>? analyzerConfigFiles = null) 
        //    : base(additionalAssemblies, references, disabledDiagnostics, analyzerConfigFiles)
        //{

        //}

        protected override IEnumerable<AnalyzerReference> GetSolutionAnalyzerReferences()
        {
            if (!_addedAnalyzers)
            {
                _addedAnalyzers = true;
                return base.GetSolutionAnalyzerReferences();
            }
            return Enumerable.Empty<AnalyzerReference>();
        }
    }
}
